package com.poly.police.monitor.admin.controller.sys;

import com.poly.police.monitor.application.service.sys.ISysLogsServer;
import com.poly.police.monitor.common.core.AjaxResult;
import com.poly.police.monitor.common.core.PageResult;
import com.poly.police.monitor.pojo.validate.commons.PageValidate;
import com.poly.police.monitor.pojo.validate.sys.SysSearchLoginsValidate;
import com.poly.police.monitor.pojo.validate.sys.SysSearchOperateValidate;
import com.poly.police.monitor.pojo.vo.sys.SysLogLoginVo;
import com.poly.police.monitor.pojo.vo.sys.SysLogOperateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/sys/log")
@Api(tags = "系统日志管理")
public class SysLogsController {

    @Resource
    ISysLogsServer iSysLogsServer;

    @GetMapping("/operate")
    @ApiOperation(value="系统操作日志")
    public AjaxResult<PageResult<SysLogOperateVo>> operate(@Validated PageValidate pageValidate,
                                                              @Validated SysSearchOperateValidate searchValidate) {
        PageResult<SysLogOperateVo> list = iSysLogsServer.operate(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/login")
    @ApiOperation(value="系统登录日志")
    public AjaxResult<PageResult<SysLogLoginVo>> login(@Validated PageValidate pageValidate,
                                                          @Validated SysSearchLoginsValidate searchValidate) {
        PageResult<SysLogLoginVo> list = iSysLogsServer.login(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

}
